Nakama Tournaments
トーナメントの設計方法を学ぶ
player が tournament を見つける方法
参加できるトーナメント
スコアの送信が許可されるタイミング
終了時の報酬の分配ルール
Rules
Tournament は リセットスケジュール、期間を設定できる(option)
cron式で設定できる
Tournament は対戦人数の制限できる。(先着)
スコアを送信するために、 tournamentに参加する必要がある。
Tournament はプログラムで作成され、特別な設定の Leaderbouardとして扱われる
Join
code: .sh
-H 'Authorization: Bearer <session token>'
List
code: .sh
-H 'Authorization: Bearer <session token>'
List tournament records
code:.sh
-H 'Authorization: Bearer <session token>'
List recourd by owner
code: .sh
-H 'Authorization: Bearer <session token>'
Write tournament records
自分のスコアを submit する
code: .sh
-H 'Authorization: Bearer <session token>'
Authoritive tournament
lua または go で書いたカスタムロジックを使うと、
トーナメントに追加ルールを適用できる
ランク制限
レベル制限
など
Create tournament
トーナメントの作成はサーバーサイドでしか出来ない
code: .lua
local id = "4ec4f126-3f9d-11e7-84ef-b7c182b36521"
local authoritative = false
local sort = "desc" -- one of: "desc", "asc"
local operator = "best" -- one of: "best", "set", "incr"
local reset = "0 12 * * *" -- noon UTC each day
local metadata = {
weather_conditions = "rain"
}
title = "Daily Dash"
description = "Dash past your opponents for high scores and big rewards!"
category = 1
start_time = nk.time() / 1000 -- starts now in seconds
end_time = 0 -- never end, repeat the tournament each day forever
duration = 3600 -- in seconds
max_size = 10000 -- first 10,000 players who join
max_num_score = 3 -- each player can have 3 attempts to score
join_required = true -- must join to compete
nk.tournament_create(id, sort, operator, duration, reset, metadata, title, description, category,
start_time, endTime, max_size, max_num_score, join_required)
開始時間
終了時間(0の場合は期間ごとにエンドレス)
duration : リセット期間
max_size: 最大プレイヤー数
max_score_num
join_required
Delete
code: .lua
local id = "4ec4f126-3f9d-11e7-84ef-b7c182b36521"
nk.tournament_delete(id)
Add store attempts
code: .lua
local id = "someid"
local owner = "someuserid"
local attempts = 10
nk.tournament_add_attempt(id, owner, attempts)
サーバーからも、スコアを追加できる
Reward distribution
報酬の分配
トーナメントの開催期間が終了したら、登録されている関数を呼び出す。
code: .lua
local nk = require("nakama")
local function distribute_rewards(_context, tournament, session_end, expiry)
// ...
end
nk.register_tournament_end(distribute_rewards)
シンプルな実装だと、
配布がある人に永続メッセージで通知 (上位 ~名とか)
virtual wallet に報酬アイテムを追加しておく
Advanced: Leaque system
トーナメントシステムは、リーグシステムの実装に応用できる
リーグ = 同じリセットスケジュールと期間を共有するトーナメントのコレクション
ランクアップあり
報酬分配